<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="../js/jquery-easyui/themes/icon.css">
    <link rel="stylesheet" href="../js/jquery-easyui/themes/bootstrap/easyui.css">
    <script src="../js/jquery.min.js" type="text/javascript"></script>
    <script src="../js/jquery-easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../js/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../js/jquery-easyui/datagrid-detailview.js"></script>
    <script src="../js/jquery.form.js"></script>
    <script src="../js/jquery.serialize-object.js"></script>
    <title>账目查询</title>

</head>
<body style="padding: 0;margin: 0;position:relative;">
<div style="height:100%;width:100%;" class="easyui-layout" fit='true'>
    <div  region="center" style="width:100%" class="easyui-layout"   title="账目查询" border="false">
        <div region='north' id="tb" style="width: 30%; height: 45px;" >
            <table style="margin-left:30px;float:left;height:45px;width: 100%;" cellspacing="0" border="0" >
                <tr >
                    <td>
                        <form id="search_form">
                        开始日期：<input id="dBeginDate" name="dBeginDate" style="width:120px;" class="easyui-datebox" />
                        结束日期：<input id="dEndDate" name="dEndDate" style="width:120px;" class="easyui-datebox"  />
                        <a href="#" class="easyui-linkbutton search" iconCls="icon-search" onclick="query()">查询</a>
                        </form>
                    </td>
                </tr>
            </table>
        </div>
        <table region='center' style="height: auto;max-height: 100%" id="listgrid" class='easyui-datagrid'  iconCls="icon-edit" toolbar="#tb"
               data-options="
               url:'/getAccounts_web',
               fit:true,
               pagination:true,
               rownumbers:true,
               singleSelect:true,
               fitColumns:true,
               showFooter:true,
               columns:[[
               {field:'dcreatetime',title:'账目创建时间',width:80,formatter: formatdate},
               {field:'dchangetime',title:'最后修改时间',width:80,formatter: formatdate},
               {field:'snickname',title:'所属用户',width:50,formatter:format_snickname},
               {field:'stypename',title:'打卡类型',width:50,formatter:format_stypename},
               {field:'namount',title:'单笔账单金额',width:50,formatter:format_namount},
               {field:'stypename2',title:'类目名称',width:50,formatter:format_stypename2},
               {field:'sbak',title:'备注',width:50,formatter:format_sbak},
               {field:'nenable',title:'账目类型',width:40,formatter:format_nenable},
               {field:'nenable2',title:'类别状态',width:60,formatter:format_nenable2}
        ]]
        "></table>
    </div>
</div>
<script type="text/javascript">

    function format_snickname(value,row,rowIndex) {
        if(row.tuser!=undefined){
            return row.tuser.snickname;
        }
    }
    function format_stypename(value,row,rowIndex) {
        if(row.tsignintype.stypename!=undefined){
            return row.tsignintype.stypename;
        }
    }
    function format_namount(value,row,rowIndex) {
        if(row.tAccountsInfo.namount!=undefined){
            return row.tAccountsInfo.namount;
        }
    }
    function format_stypename2(value,row,rowIndex) {
        if(row.tAccountsInfo.taccountstype.stypename!=undefined){
            return row.tAccountsInfo.taccountstype.stypename;
        }
    }
    function format_sbak(value,row,rowIndex) {
        if(row.tsignintype.sbak!=undefined){
            return row.tsignintype.sbak;
        }
    }
    function format_nenable(value,row,rowIndex) {
        if(row.tAccountsInfo.taccountstype.nenable!=undefined){
            var  nenable=row.tAccountsInfo.taccountstype.nenable;
            if(nenable==0){
                return '支出';
            }else if(nenable==1){
                return "收入";
            }else if(nenable==2){
                return "不计";
            }
        }
    }
    function format_nenable2(value,row,rowIndex) {
        if(row.tAccountsInfo.taccountstype.nEnable2!=undefined){
            var  nenable2=row.tAccountsInfo.taccountstype.nEnable2;
            if(nenable2==0){
                return '普通无详情';
            }else if(nenable2==1){
                return "基本工资";
            }else if(nenable2==2){
                return "计件";
            }else if(nenable2==3){
                return "计算提成";
            }
        }
    }

    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, // month
            "d+": this.getDate(), // day
            "h+": this.getHours(), // hour
            "m+": this.getMinutes(), // minute
            "s+": this.getSeconds(), // second
            "q+": Math.floor((this.getMonth() + 3) / 3), // quarter
            "S": this.getMilliseconds()
            // millisecond
        }
        if (/(y+)/.test(format))
            format = format.replace(RegExp.$1, (this.getFullYear() + "")
                .substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    function formatdate(value,row,index) {
        if (value == null || value == '') {
            return '';
        }
        var dt;
        if (value instanceof Date) {
            dt = value;
        } else {
            dt = new Date(value);
        }
        return dt.format("yyyy-MM-dd");
    }

    //  查找
    function query(){
        $('#listgrid').datagrid('load',$('#search_form').serializeObject());
    }


</script>
</body>
</html>